<?php
// 获取 当前URL
$url = $_SERVER['PHP_SELF'];
// 根据/分割route
$arr = explode('/', $url);
$arr2 = explode('.', $arr[2]);
$route = $arr2[0];
// 组织菜单的数组
$urls = array(
    '概览' => 'index',
    '用户增减数据(日)' => 'usersummary_day',
    '用户增减数据(月)' => 'usersummary',
    '图文群发每日数据' => 'articlesummary',
    '图文群发总数据' => 'articletotal',
    '图文统计数据' => 'read',
    '图文分享转发数据' => 'usershare',
    '微信群签到' => 'wxsign',
    '销售线索' => 'clue',
//    '百度流量数据' => 'baidu',
);
if ($route == 'index') {
    $name = '概览';
} elseif ($route == 'usersummary') {
    $name = '用户增减数据(月)';
} elseif ($route == 'usersummary_day') {
    $name = '用户增减数据(日)';
} elseif ($route == 'articlesummary') {
    $name = '图文群发每日数据';
} elseif ($route == 'articletotal') {
    $name = '图文群发总数据';
} elseif ($route == 'read') {
    $name = '图文统计数据';
} elseif ($route == 'usershare') {
    $name = '图文分享转发数据';
} elseif ($route == 'wxsign') {
    $name = '微信群签到';
} elseif ($route == 'clue') {
    $name = '销售线索';
}
//elseif ($route == 'baidu') {
//    $name = '百度流量数据';
//}
?>
<!DOCTYPE html>
<html>
    <head>
        <title><?=$name ?> - 普元市场部数据集成平台</title>
        <meta charset="utf-8">
        <!-- 引入 ECharts 文件 -->
        <link rel="stylesheet" href="static/bootstrap.min.css">
        <link rel="stylesheet" href="static/jquery-ui.min.css">
        <link rel="stylesheet" href="static/dashboard.css">
        <script src="static/echarts.js"></script>
        <script src="static/jquery-3.1.1.min.js"></script>
        <script src="static/jquery-ui.min.js"></script>
        <script src="static/bootstrap.min.js"></script>
    </head>
    <body>
        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">普元市场部数据集成平台</a>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">Help</a></li>
                    </ul>
                </div>
            </div>
        </nav>
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-3 col-md-2 sidebar">
                    <ul class="nav nav-sidebar">
                        <?php
                        // 根据路径route设置左侧菜单
                        foreach ($urls as $key => $url) {
                            if ($url == $route) {
                                echo '<li class="active"><a href="' . $url . '.php">' . $key . '</a></li>';
                            } else {
                                echo '<li><a href="' . $url . '.php">' . $key . '</a></li>';
                            }
                        }
                        ?>
                    </ul>
                </div>
                <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                    <h1><strong id="chart_title"><?= $name ?></strong> · 在线图表</h1>
                    <br>
                    <form class="form-inline">
                        <div class="form-group">
                            <label>日期：</label>
                            <input type="text" id="datepicker1" name="datepicker1" placeholder="开始日期">
                        </div>
                        <div class="form-group">
                            <label>-</label>
                            <input type="text" id="datepicker2" name="datepicker2" placeholder="结束日期">
                        </div>
                        <input type="button" value="查询" onclick="jsonData()">
                    </form>
                    <br>
                    <p><em>提示</em>：可选择时间段查询数据.</p>
                    <hr>
                    <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
                    <div id="main" style="width: 100%;height:400px;"></div>
                    <br>
                    <table id="table"  class="table table-bordered" style="margin-bottom: 20px;"></table>
                </div>
            </div>                